<template>
    <swiper>
        <swiper-item v-for="(item,index) in banners">
            <a>
                <img :src="item.image"
                     ali=""
                     @load="imageLoad" />
            </a>
        </swiper-item>
    </swiper>
</template>
<script>
import { Swiper, SwiperItem } from '../../../components/common/swiper/index';
export default {
    name: "HomeSwiper",
    components: {
        Swiper,
        SwiperItem
    },
    data: function () {
        return {
            imageLoadFlag: false
        }
    },
    props: {
        banners: {
            type: Array,
            default: function () {
                return []
            }
        }
    },
    methods: {
        imageLoad: function () {
            //once无效，因为每个图片都可执行一次，和设计不符合
            if (!this.imageLoadFlag) {
                this.$emit('swiperImageLoaded');
                this.imageLoadFlag = true;
            }
        }
    }
}
</script>
<style scoped>
</style>